package com.spring.shops.service.impl;

import com.spring.shops.dao.TzUserMapper;
import com.spring.shops.model.dto.VipUserDTO;
import com.spring.shops.model.entity.TzUser;
import com.spring.shops.model.vo.VipPageVo;
import com.spring.shops.service.VipUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class VipUserServiceImpl implements VipUserService {

    @Resource
    private TzUserMapper userMapper;
    @Override
    public VipPageVo selectByPage(VipPageVo vipPageVo,String nickName,int status){


        VipUserDTO vipUserDTO =new VipUserDTO();
        vipUserDTO.setNickName(nickName);
        vipUserDTO.setStatus(status);
        vipUserDTO.setCurrent(vipPageVo.getCurrent()-1);
        vipUserDTO.setSize(vipPageVo.getSize());

        TzUser[] tzUsers=userMapper.selectByPageSearch(vipUserDTO);
        long total=tzUsers.length;
        vipPageVo.setTotal(total);
        vipPageVo.setRecords(tzUsers);
        return vipPageVo;
    }

    @Override
    public TzUser selectByUserId(String userId){
        TzUser tzUser = userMapper.selectByPrimaryKey(userId);
        return tzUser;
    }
    @Override
    public int updateStatus(TzUser tzUser){
        int i = userMapper.updateByPrimaryKeySelective(tzUser);
        return i;
    }
}
